using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Drawing;


namespace SBPweb.Themes.Windows.Skins
{
	/// <summary>
	/// Class of Colors
	/// </summary>
	public class Colors
	{
		private System.Drawing.Color mBackColor = new System.Drawing.Color();
		private System.Drawing.Color mForeColor = new System.Drawing.Color();

		/// <summary>
		/// Constructor of Colors
		/// </summary>
		public Colors()
		{
		}

		/// <summary>
		/// Constructor of Colors
		/// </summary>
		/// <param name="backColor">backcolor</param>
		/// <param name="foreColor">forecolor</param>
		public Colors(System.Drawing.Color backColor, System.Drawing.Color foreColor)
		{
			mBackColor = backColor;
			mForeColor = foreColor;
		}

		/// <summary>
		/// Constructor of Colors
		/// </summary>
		/// <param name="node">xml node</param>
		public Colors(XmlNode node)
		{
			XmlAttribute backAtt = node.Attributes["BackColor"];
			XmlAttribute foreAtt = node.Attributes["ForeColor"];
			
			if (node != null)
			{
				if (backAtt != null)
				{
					string[] bcStr = backAtt.Value.Split(',');
					if (bcStr.Length != 3)
					{
						if (!backAtt.Value.StartsWith("$"))
							mBackColor = Color.FromName(backAtt.Value);
					}
					else
						mBackColor = Color.FromArgb(Byte.Parse(bcStr[0]), Byte.Parse(bcStr[1]), Byte.Parse(bcStr[2]));
				}

				if (foreAtt != null)
				{
					string[] fcStr = foreAtt.Value.Split(',');
					if (fcStr.Length != 3)
					{
						if (!backAtt.Value.StartsWith("$"))
							mForeColor = Color.FromName(foreAtt.Value);
					}
					else
						mForeColor = Color.FromArgb(Byte.Parse(fcStr[0]), Byte.Parse(fcStr[1]), Byte.Parse(fcStr[2]));
				}
			}

		}

		/// <summary>
		/// Backcolor
		/// </summary>
		public System.Drawing.Color BackColor
		{
			get
			{
				return mBackColor;
			}
			set
			{
				mBackColor = value;
			}
		}

		/// <summary>
		/// Forecolor
		/// </summary>
		public System.Drawing.Color ForeColor
		{
			get
			{
				return mForeColor;
			}
			set
			{
				mForeColor = value;
			}
		}
	}
}
